package fr.znight.chacunsatv.service;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;

import android.util.Log;


public class ChatClient{
	
	boolean end=false;
	
	String msgFromTV="";
	
	
	 public ChatClient(){
	
		 
		 

	        
         try {
                 
                 InetAddress serverAddr = InetAddress.getByName("192.168.0.108");//TCPServer.SERVERIP
                 
                 //Log.d("TCP", "C: Connecting...");
                 //Socket socket = new Socket(serverAddr, TCPDesktopServer.SERVERPORT);
                 
                 
                 
                 String message = "";
                 
                 while(true){
                         
                         
                                                 
                         Socket socket = new Socket(serverAddr, 12345);
                 
                
                         message="Hello";
                         
                         
                         
                         
                 
                     try {
                         PrintWriter out = new PrintWriter( new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())),true);
                         
                         out.println(message);
                         
             } catch(Exception e) {
                 //Log.e("TCP", "S: Error", e);
                      }
                 
             finally {
                        socket.close();
                      }
             
             
                 Thread.sleep(1000);

             
                 }
         } catch (Exception e) {
              //Log.e("TCP", "C: Error", e);
         }
         
         
    }
		 
	 
	
	
}